<?php
/**
 * View Archivio Post LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    21-apr-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
$today_date = getdate();
?>
<script type="text/javascript" src="/js/jquery.pajinate.min.js"></script>
<script type="text/javascript">
    //<![CDATA[

    $(document).ready(function(){
        
        $('#activity-list.list').pajinate({
                                    items_per_page : 2,
                                    item_container_id : '#activities',
                                    nav_panel_id : '.pagination',
                                    nav_label_prev: '&nbsp;',
                                    nav_label_next: '&nbsp;',
                                    show_first_last : false

                            });
        
        var shared = {
            content: {
            text: function(api) {
                // Retrieve content from custom attribute of the $('.selector') elements.
                return $(this).next('div.tooltip').clone();
                }
            },            
            position: {
                my: 'bottom center',  // Position my top left...
                at: 'top center' // at the bottom right of...
                //target: $('.selector') // my target
            },
            style: {
                classes: 'ui-tooltip-shadow ui-tooltip-dark  ui-tooltip-rounded'
            }
        };        
        
        $("img.description-icon").qtip( $.extend({}, shared));
        $("img.clock-icon").qtip( $.extend({}, shared));
        $("img.recurring").qtip( $.extend({}, shared));
        $("span.closed").qtip( $.extend({}, shared));
        //console.dir($("img.description-icon").qtip());
//        $("img.description-icon").tooltip({ effect: 'slide' });
//        $("img.clock-icon").tooltip({ effect: 'slide' });
//        $("img.recurring").tooltip({ effect: 'slide' });
        
    });
    //]]>
</script>
<div id="content">
    <div id="summary" class="activities">
        <div class="head activities">
            <h2>Elenco Attivit&agrave;</h2>
        </div>
        <div class="body">
            <div class="widget">
                <strong>Live Da Confermare</strong> 
                <var class="color1">11</var> 
                <em>Number</em>
            </div>
            <div class="widget">
                <strong>Recall</strong> 
                <var class="color1">11</var> 

            </div>

            <br class="clear"/>

        </div>	
    </div>
    <div class="help">
        <h2>Info</h2>
        <br/>Sono evidenziate le attivit&agrave; di oggi.
        <br/>L'icona <img src="/images/admin/16x16/arrow_refresh_small.png" /> si riferisce ad attivit&agrave; ricorrenti (passa il mouse sopra per vedere i dettagli).
        <br/>L'icona <img src="/images/admin/16x16/information.png" /> indica la descrizione dell'attivit&agrave; (passa il mouse sopra per vedere i dettagli).
        <br/>L'icona <img src="/images/admin/16x16/clock_alert.png" /> indica la presenza di orari (passa il mouse sopra per vedere i dettagli).
    </div>
    <form>
        <ul>
            <li class="addnew">
                <a class="button" href="/admin/attivita/info">
                    <img src="/images/admin/16x16/add-new.png" />Nuova Attivit&agrave;
                </a>
                <a class="button" href="/admin/attivita/agenda">
                    <img src="/images/admin/calendar.png" />Vai a Agenda
                </a>
            </li>
        </ul>
    </form>
    
    <table class="log clearfix table list " id="activity-list">
        <tbody>
            <?php if( count( $this->activities ) ) : ?>
                <?php if( count( $this->activities['today'] ) ) : ?>
                    <tr class="today">
                        <td class="date">
                            <h3>
                                <b>Oggi</b>
                                <span><?php echo $today_date['mday'] ?> <?php echo $this->months[sprintf( '%01d', $today_date['mon'] )] ?> <?php echo $today_date['year'] ?></span>
                            </h3>		
                        </td>
                        <td>
                            <div class="day">
                            <?php 
                            foreach( $this->activities['today'] as $activity ): 
                                list( $to_y, $to_m, $to_d ) = explode( '-', $activity['activity_end_date'] );
                                ?>
                                <div class="activity">
                                    <div class="title">
                                        <strong>
                                            <?php echo $activity['activity_title'] ?>
                                        </strong>
                                        <?php if( !is_null( $activity['activity_end_date'] ) ): ?>
                                        <img class="recurring" src="/images/admin/16x16/arrow_refresh_small.png" />
                                        <div class="tooltip">
                                            Fino al <?php echo $to_d ?> <?php echo $this->months[sprintf( '%01d', $to_m )] ?> <?php echo $to_y ?>
                                        </div>                                    
                                        <?php endif; ?>                                            
                                    </div>
                                    <div class="time">&nbsp;
                                        <?php if( !is_null( $activity['activity_start_time'] ) OR !is_null( $activity['activity_end_time'] ) ) : ?>
                                        <a href="">
                                            <img class="clock-icon" src="/images/admin/16x16/clock_alert.png">
                                            <div class="tooltip">
                                                <?php echo $activity['activity_start_time'] != null ? 'Dalle <strong>'. $activity['activity_start_time_ita'] .'</strong><br/>' : '' ?>
                                                <?php echo $activity['activity_end_time'] != null ? 'Fino alle <strong>'. $activity['activity_end_time_ita'] .'</strong>' : '' ?>
                                            </div>
                                        </a>
                                        <?php endif; ?>
                                    </div>                                    
                                    <div class="description">&nbsp;
                                    <?php if( !is_null( $activity['activity_description'] ) ) : ?>
                                    <a href="">
                                        <img class="description-icon" src="/images/admin/16x16/information.png">
                                        <div class="tooltip">
                                            <?php echo $activity['activity_description'] ?>
                                        </div>
                                    </a>
                                    <?php endif; ?>
                                    </div>
                                    <div class="assignedto">&nbsp;
                                        <?php echo !is_null( $activity['activity_assignedto'] ) ? 'Assegnato a: <b>'. $activity['user_firstname'] .' '. $activity['user_lastname'] .'</b>' : '' ?>
                                    </div>
                                    <?php if( $activity['activity_status'] == 1 ) : ?>
                                        <span class="close">
                                            <a href="/admin/attivita/chiudi/id/<?php echo $activity['activity_id'] ?>"><img src="/images/admin/16x16/tick-button.png">Chiudi</a>
                                        </span>
                                        <span class="actions">
                                            <a class="edit" title="Edit" href="/admin/attivita/info/id/<?php echo $activity['activity_id'] ?>">&nbsp;</a>
                                            <a class="del" title="Cancella" href="">&nbsp;</a>
                                        </span>
                                    <?php else: ?>
                                        <span class="closed">
                                            <img class="closed" src="/images/admin/16x16/tick.png">Chiusa
                                        </span>
                                            <div class="tooltip">
                                                Chiusa da: <strong><?php echo $activity['closedby']['user_firstname'] ?> <?php echo $activity['closedby']['user_lastname'] ?></strong>
                                                <br/>il <strong><?php echo $activity['activity_modified_ita'] ?></strong>
                                            </div>                                          
                                        <span class="actions">

                                        </span>
                                    <?php endif; ?>
                                </div>
                            <?php endforeach;?>      
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>

                <?php if( count( $this->activities['tomorrow'] ) ) : ?>
                    <tr class="selectable">
                        <td class="date">
                            <h3>
                                <b>Domani</b>
                                <span><?php echo $d ?> <?php echo $this->months[sprintf( '%01d', $m )] ?> <?php echo $y ?></span>
                            </h3>		
                        </td>
                        <td>
                            <div class="day">
                            <?php 
                            foreach( $this->activities['tomorrow'] as $activity ): 
                                list( $to_y, $to_m, $to_d ) = explode( '-', $activity['activity_end_date'] );
                                ?>
                                <div class="activity">
                                    <div class="title">
                                        <strong><?php echo $activity['activity_title'] ?></strong>
                                        <?php if( !is_null( $activity['activity_end_date'] ) ): ?>
                                        <img class="recurring" src="/images/admin/16x16/arrow_refresh_small.png" />
                                        <div class="tooltip">
                                            Fino al <?php echo $to_d ?> <?php echo $this->months[sprintf( '%01d', $to_m )] ?> <?php echo $to_y ?>
                                        </div>                                        
                                        <?php endif; ?>                                        
                                    </div>
                                    <div class="time">&nbsp;
                                        <?php if( !is_null( $activity['activity_start_time'] ) OR !is_null( $activity['activity_end_time'] ) ) : ?>
                                        <a href="">
                                            <img class="clock-icon" src="/images/admin/16x16/clock_alert.png">
                                            <div class="tooltip">
                                                <?php echo $activity['activity_start_time'] != null ? 'Dalle <strong>'. $activity['activity_start_time_ita'] .'</strong><br/>' : '' ?>
                                                <?php echo $activity['activity_end_time'] != null ? 'Fino alle <strong>'. $activity['activity_end_time_ita'] .'</strong>' : '' ?>
                                            </div>
                                        </a>
                                        <?php endif; ?>
                                    </div>                                    
                                    <div class="description">&nbsp;
                                    <?php if( !is_null( $activity['activity_description'] ) ) : ?>
                                    <a href="">
                                        <img class="description-icon" src="/images/admin/16x16/information.png">
                                        <div class="tooltip">
                                            <?php echo $activity['activity_description'] ?>
                                        </div>
                                    </a>
                                    <?php endif; ?>
                                    </div>
                                    <div class="assignedto">&nbsp;
                                        <?php echo !is_null( $activity['activity_assignedto'] ) ? 'Assegnato a: <b>'. $activity['user_firstname'] .' '. $activity['user_lastname'] .'</b>' : '' ?>
                                    </div>
                                    <?php if( $activity['activity_status'] == 1 ) : ?>
                                        <span class="close">
                                            <a href="/admin/attivita/chiudi/id/<?php echo $activity['activity_id'] ?>"><img src="/images/admin/16x16/tick-button.png">Chiudi</a>
                                        </span>
                                        <span class="actions">
                                            <a class="edit" title="Edit" href="/admin/attivita/info/id/<?php echo $activity['activity_id'] ?>">&nbsp;</a>
                                            <a class="del" title="Cancella" href="">&nbsp;</a>
                                        </span>
                                    <?php else: ?>
                                        <span class="closed">
                                            <img class="closed" src="/images/admin/16x16/tick.png">Chiusa
                                        </span>
                                            <div class="tooltip">
                                                Chiusa da: <strong><?php echo $activity['closedby']['user_firstname'] ?> <?php echo $activity['closedby']['user_lastname'] ?></strong>
                                                <br/>il <strong><?php echo $activity['activity_modified_ita'] ?></strong>
                                            </div>                                          
                                        <span class="actions">

                                        </span>
                                    <?php endif; ?>
                                </div>
                            <?php endforeach;?>      
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>
                    
                <?php if( count( $this->activities['current'] ) ) : ?>
                    <tr class="selectable">
                        <td class="date">
                            <h3>
                                <b>In corso</b>
                            </h3>		
                        </td>
                        <td>
                            <div class="day">
                            <?php 
                            foreach( $this->activities['current'] as $activity ): 
                                list($to_y, $to_m, $to_d ) = explode( '-', $activity['activity_end_date'] );
                                ?>
                                <div class="activity">
                                    <div class="title">
                                        <?php if( !is_null( $activity['activity_end_date'] ) ): ?>
                                        <img class="recurring" src="/images/admin/16x16/arrow_refresh_small.png" />
                                        <div class="tooltip">
                                            Fino al <?php echo $to_d ?> <?php echo $this->months[sprintf( '%01d', $to_m )] ?> <?php echo $to_y ?>
                                        </div>                                     
                                        <?php endif; ?>
                                        <strong><?php echo $activity['activity_title'] ?></strong>
                                    </div>
                                    <div class="time">&nbsp;
                                        <?php if( !is_null( $activity['activity_start_time'] ) OR !is_null( $activity['activity_end_time'] ) ) : ?>
                                        <a href="">
                                            <img class="clock-icon" src="/images/admin/16x16/clock_alert.png">
                                            <div class="tooltip">
                                                <?php echo $activity['activity_start_time'] != null ? 'Dalle <strong>'. $activity['activity_start_time_ita'] .'</strong><br/>' : '' ?>
                                                <?php echo $activity['activity_end_time'] != null ? 'Fino alle <strong>'. $activity['activity_end_time_ita'] .'</strong>' : '' ?>
                                            </div>
                                        </a>
                                        <?php endif; ?>
                                    </div>
                                    <div class="description">&nbsp;
                                    <?php if( !is_null( $activity['activity_description'] ) ) : ?>
                                    <a href="">
                                        <img class="description-icon" src="/images/admin/16x16/information.png">
                                        <div class="tooltip">
                                            <?php echo $activity['activity_description'] ?>
                                        </div>
                                    </a>
                                    <?php endif; ?>
                                    </div>
                                    <div class="assignedto">&nbsp;
                                        <?php echo !is_null( $activity['activity_assignedto'] ) ? 'Assegnato a: <b>'. $activity['user_firstname'] .' '. $activity['user_lastname'] .'</b>' : '' ?>
                                    </div>
                                    <?php if( $activity['activity_status'] == 1 ) : ?>
                                        <span class="close">
                                            <a href="/admin/attivita/chiudi/id/<?php echo $activity['activity_id'] ?>"><img src="/images/admin/16x16/tick-button.png">Chiudi</a>
                                        </span>
                                        <span class="actions">
                                            <a class="edit" title="Edit" href="/admin/attivita/info/id/<?php echo $activity['activity_id'] ?>">&nbsp;</a>
                                            <a class="del" title="Cancella" href="">&nbsp;</a>
                                        </span>
                                    <?php else: ?>
                                        <span class="closed">
                                            <img class="closed" src="/images/admin/16x16/tick.png">Chiusa
                                        </span>
                                            <div class="tooltip">
                                                Chiusa da: <strong><?php echo $activity['closedby']['user_firstname'] ?> <?php echo $activity['closedby']['user_lastname'] ?></strong>
                                                <br/>il <strong><?php echo $activity['activity_modified_ita'] ?></strong>
                                            </div>                                          
                                        <span class="actions">

                                        </span>
                                    <?php endif; ?>
                                </div>
                            <?php endforeach;?>      
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>                       
                    
            <?php endif; ?>
            
<!--		    Questo contenuto verrà  rimpiazzato dalla paginazione-->

        </tbody>
    </table>
    <br/>
    <br/>
    <br/>
    <table class="log clearfix table list " id="activity-list">
	<thead>
	    <tr>
                <td class="pagination" colspan="2">
                    <a class="prev" href="javascript: void(0);">&nbsp;</a>
                    <span class="loader">Sto caricando...</span>
                    <a class="next" href="javascript: void(0);">&nbsp;</a>
		</td>
	    </tr>
	</thead>
        <tbody id="activities">
        <?php 
            if ( count($this->activities) > 0 ) :
                foreach( $this->activities as $k => $day ):

                // Bypassiamo le date passate...
                if( strtotime( $k ) < strtotime( $today ) )
                    continue;

                if( !in_array( $k, array('today', 'tomorrow', 'current') ) ):

                    list($y, $m, $d ) = explode( '-', $k );
                    ?>
                    <tr class="selectable">
                        <td class="date">
                            <h3>
                                <b><?php echo $d ?> <?php echo $this->months[sprintf( '%01d', $m )] ?> <?php echo $y ?></b>
                                <span><?php echo $this->days[date( 'N', mktime( $hour, $minute, $second, $m, $d, $y ) )] ?></span>
                            </h3>		
                        </td>
                        <td>
                            <div class="day">
                            <?php foreach( $day as $activity ): 
                                list( $to_y, $to_m, $to_d ) = explode( '-', $activity['activity_end_date'] );
                                ?>
                                <div class="activity">
                                    <div class="title">
                                        <strong><?php echo $activity['activity_title'] ?></strong>
                                        <?php if( !is_null( $activity['activity_end_date'] ) ): ?>
                                        <img class="recurring" src="/images/admin/16x16/arrow_refresh_small.png" />
                                        <div class="tooltip">
                                            Fino al <?php echo $to_d ?> <?php echo $this->months[sprintf( '%01d', $to_m )] ?> <?php echo $to_y ?>
                                        </div>                                            
                                        <?php endif; ?>                                            
                                    </div>
                                    <div class="time">&nbsp;
                                        <?php if( !is_null( $activity['activity_start_time'] ) OR !is_null( $activity['activity_end_time'] ) ) : ?>
                                        <a href="">
                                            <img class="clock-icon" src="/images/admin/16x16/clock_alert.png">
                                            <div class="tooltip">
                                                <?php echo $activity['activity_start_time'] != null ? 'Dalle <strong>'. $activity['activity_start_time_ita'] .'</strong><br/>' : '' ?>
                                                <?php echo $activity['activity_end_time'] != null ? 'Fino alle <strong>'. $activity['activity_end_time_ita'] .'</strong>' : '' ?>
                                            </div>
                                        </a>
                                        <?php endif; ?>
                                    </div>                                    
                                    <div class="description">&nbsp;
                                    <?php if( !is_null( $activity['activity_description'] ) ) : ?>
                                    <a href="">
                                        <img class="description-icon" src="/images/admin/16x16/information.png">
                                        <div class="tooltip">
                                            <?php echo $activity['activity_description'] ?>
                                        </div>
                                    </a>
                                    <?php endif; ?>
                                    </div>
                                    <div class="assignedto">&nbsp;
                                        <?php echo !is_null( $activity['activity_assignedto'] ) ? 'Assegnato a: <b>'. $activity['user_firstname'] .' '. $activity['user_lastname'] .'</b>' : '' ?>
                                    </div>
                                    <?php if( $activity['activity_status'] == 1 ) : ?>
                                        <span class="close">
                                            <a href="/admin/attivita/chiudi/id/<?php echo $activity['activity_id'] ?>"><img src="/images/admin/16x16/tick-button.png">Chiudi</a>
                                        </span>
                                        <span class="actions">
                                            <a class="edit" title="Edit" href="/admin/attivita/info/id/<?php echo $activity['activity_id'] ?>">&nbsp;</a>
                                            <a class="del" title="Cancella" href="">&nbsp;</a>
                                        </span>
                                    <?php else: ?>
                                        <span class="closed">
                                            <img class="closed" src="/images/admin/16x16/tick.png">Chiusa
                                        </span>
                                            <div class="tooltip">
                                                Chiusa da: <strong><?php echo $activity['closedby']['user_firstname'] ?> <?php echo $activity['closedby']['user_lastname'] ?></strong>
                                                <br/>il <strong><?php echo $activity['activity_modified_ita'] ?></strong>
                                            </div>                                          
                                        <span class="actions">

                                        </span>
                                    <?php endif; ?>
                                </div>
                            <?php endforeach;?>            
                            </div>
                        </td>
                    </tr>

                <?php 
                endif; 
            endforeach;
        endif;?>    
        </tbody>
        <tfoot>
	    <tr>
                <td class="pagination" colspan="2">
                    <a class="prev" href="javascript: void(0);">&nbsp;</a>
                    <span class="loader">Sto caricando...</span>
                    <a class="next" href="javascript: void(0);">&nbsp;</a>
		</td>
	    </tr>
        </tfoot>
    </table>  
</div>

